//
//  NoticeViewController.m
//  Supervisor
//
//  Created by 小宇 on 2017/5/10.
//  Copyright © 2017年 北京怀教网络科技股份有限公司. All rights reserved.
//

#import "NoticeViewController.h"
#import "CommentTableViewCell.h"
#import "NoticeDetailViewController.h"
#import "NoticeModel.h"
@interface NoticeViewController ()
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)NSMutableArray *noticeList;
@end

@implementation NoticeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (NSString *)setNavTitle{
    return @"通知公告";
}

- (NSDictionary *)sendParameterWithRefreshGet{
    NSDictionary *parameterDic = @{@"pageNo":@(1),@"pageSize":@(10)};
    NSDictionary *dic = @{@"parameterDic":parameterDic,@"url":noticelist};
    return dic;
}

- (BOOL)setHeaderAndFooterRefresh{
    LZYWeakSelf(self);
    self.netWorkBlock = ^(id responseDic) {
        weakself.noticeList = [NSMutableArray arrayWithArray:[NoticeModel arrayOfModelsFromDictionaries:responseDic error:nil]];
        [weakself.tableView reloadData];
    };
    self.netWorkMoreBlock = ^(id responseDic) {
        [weakself.noticeList addObjectsFromArray:[NoticeModel arrayOfModelsFromDictionaries:responseDic error:nil]];
        [weakself.tableView reloadData];
    };
    return YES;
}

- (UITableView *)set_tableViewWithFrame{
    UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, Main_Screen_Width, Main_View_Height)];
    self.tableView = tableView;
    return self.tableView;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [self.tableView showBlankPageViewWithCount:self.noticeList];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 83;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    CommentTableViewCell *cell = [CommentTableViewCell cellWithNoticeTableView:tableView];
    [cell settingWithNoticeModel:self.noticeList[indexPath.row]];
    cell.selectionStyle = UIAccessibilityTraitNone;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    CommentTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    NoticeDetailViewController *noticeDetailVC = [NoticeDetailViewController new];
    NoticeModel *model = self.noticeList[indexPath.row];
    noticeDetailVC.noticeId = model.id;
    cell.tipLabel.hidden = YES;
    [self.navigationController pushViewController:noticeDetailVC animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
